home *** CD-ROM | disk | FTP | other *** search
/ Workbench Design / WB Collection.iso / workbench werkzeuge / scherz programme / amigaeyes / source / eyescommodity.c < prev    next >
C/C++ Source or Header  |  1996-04-07  |  4KB  |  153 lines

  1. /*****************************************************************************/
  2. /*                       AmigaEyes V1.1a (02/12/1994)                        */
  3. /*                                                                           */
  4. /*       Author: Stéphane Poirier                                            */
  5. /*               Copyright © 1994 Stéphane Poirier. All right reserved       */
  6. /*                                                                           */
  7. /*****************************************************************************/
  8.  
  9. #include <exec/types.h>
  10. #include <ctype.h>
  11. #include <clib/exec_protos.h>
  12. #include <clib/intuition_protos.h>
  13. #include <stdlib.h>
  14. #include <stdio.h>
  15. #include <exec/memory.h>
  16. #include <exec/libraries.h>
  17. #include <libraries/commodities.h>
  18. #include <dos/dos.h>
  19. #include <clib/alib_protos.h>
  20. #include <clib/commodities_protos.h>
  21.  
  22. #include "eyes.h"
  23.  
  24. #define HOTKEY 1
  25.  
  26. struct     MsgPort *EyesBrokerMsgPort = NULL;
  27. CxObj    *EyesBroker = NULL;
  28. CxObj     *Filtre, *Sender, *Trans;
  29. CxMsg    *MsgBroker;
  30. struct     Window *win = NULL;
  31.  
  32. struct NewBroker NewBroker = 
  33. {
  34.   NB_VERSION,
  35.   "AmigaEyes",
  36.   "AmigaEyes 1.1 © 1994 Stéphane Poirier",
  37.   "Big Brother is watching you !",
  38.   NBU_UNIQUE|NBU_NOTIFY,
  39.   COF_SHOW_HIDE,
  40.   0,0,0
  41. };
  42.  
  43. ULONG sigflags;
  44. BOOL Dodo;
  45. BOOL Actif = TRUE;
  46. extern struct Screen *ActiveScreen;
  47.  
  48. void StartCommodity(void)
  49. {
  50.   if ((EyesBrokerMsgPort = CreateMsgPort()) == NULL) SortiePropre();
  51.   NewBroker.nb_Port = EyesBrokerMsgPort;
  52.   sigflags = 1L << EyesBrokerMsgPort->mp_SigBit;
  53.  
  54.   NewBroker.nb_Pri = Parametres.priorite;
  55.  
  56.   if ((EyesBroker = CxBroker(&NewBroker, NULL)) == NULL) SortiePropre();
  57.  
  58.   if ((Filtre = CxFilter(hotkey)) == NULL) SortiePropre();
  59.   AttachCxObj(EyesBroker, Filtre);
  60.  
  61.   if ((Sender = CxSender(EyesBrokerMsgPort, HOTKEY)) == NULL) SortiePropre();
  62.   AttachCxObj(Filtre, Sender);
  63.   
  64.   if ((Trans = CxTranslate(NULL)) == NULL) SortiePropre();
  65.   AttachCxObj(Filtre, Trans);
  66.  
  67.   if (CxObjError(Filtre))
  68.   {
  69.     printf("erreur cx\n");
  70.     SortiePropre();
  71.   }
  72.   
  73.   ActivateCxObj(EyesBroker, TRUE);
  74. }
  75.  
  76. /*****************************************************************************/
  77. int ProcessMsg(void)
  78. {
  79.   ULONG msgid, msgtype;
  80.   BOOL running = TRUE;
  81.  
  82.   while(MsgBroker = (CxMsg *)GetMsg(EyesBrokerMsgPort))
  83.   {
  84.     msgid = CxMsgID(MsgBroker);
  85.     msgtype = CxMsgType(MsgBroker);
  86.     ReplyMsg((struct Message *)MsgBroker);
  87.     
  88.     switch(msgtype)
  89.     {
  90.       case CXM_IEVENT:
  91.         switch(msgid)
  92.         {
  93.           case HOTKEY:
  94.             if (Dodo)
  95.             {
  96.               running = ProcessActive();
  97.               Dodo = FALSE;
  98.             }
  99.             else
  100.               ActiveScreen = NULL;
  101.               running = ProcessJump(FALSE);
  102.             break;
  103.  
  104.           default:
  105.             break;
  106.         }
  107.  
  108.       case CXM_COMMAND:
  109.         switch(msgid)
  110.         {
  111.           case CXCMD_DISABLE:
  112.             running = FALSE;
  113.             Restart = TRUE;
  114.             Dodo = TRUE;
  115.             ActivateCxObj(EyesBroker, FALSE);
  116.             Actif = FALSE;
  117.             break;
  118.           
  119.           case CXCMD_ENABLE:
  120.             Dodo = FALSE;
  121.             ActivateCxObj(EyesBroker, TRUE);
  122.             Actif = TRUE;
  123.             break;
  124.             
  125.           case CXCMD_KILL:
  126.             running = FALSE;
  127.             Restart = FALSE;
  128.             Dodo = FALSE;
  129.             break;
  130.  
  131.           case CXCMD_UNIQUE:
  132.             break;
  133.           
  134.           case CXCMD_DISAPPEAR:
  135.             if (Actif)
  136.             {
  137.               running = FALSE;
  138.               Restart = TRUE;
  139.               Dodo = TRUE;
  140.             }
  141.             break;
  142.             
  143.           case CXCMD_APPEAR:
  144.             if (Actif)
  145.             {
  146.               Dodo = FALSE;
  147.             }
  148.             break;
  149.         }
  150.     }
  151.   }
  152.   return (running);
  153. }